﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

namespace DataQueryUnitTest
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void stringFormat()
        {
            var s = String.Format("{0}{0}{1}{2}{0}", "wangji", "xiaxia", "gogo");
        }
        [TestMethod]
        public void GetPointsValueByTime()
        {
            var l = new List<string>();
            var s = l.FirstOrDefault();
            var list =
               MetroDataQuery.Utility.MonitorPointsQuery.GetPointsValueByDate(17, "沉降", "下行线", "2012-11-27", true);

        }

        [TestMethod]
        public void GetOriginMonitorTime()
        {
            var time = MetroDataQuery.Utility.MonitorPointsQuery.GetOrigin(17, "LevelPoints1", "XX01");
        }


        [TestMethod]
        public void GetTimeList()
        {
            var time = MetroDataQuery.Utility.MonitorPointsQuery.GetMonitorTimeList(17, "沉降", "下行线");

            var time2 = MetroDataQuery.Utility.MonitorPointsQuery.GetMonitorTimeList(17, "沉降", "下行线", "", "", 2);

            var badTimeList = MetroDataQuery.Utility.MonitorPointsQuery.GetMonitorTimeList(17, "沉降", "下行线", "2011-1-1");

            var badTimeList1 = MetroDataQuery.Utility.MonitorPointsQuery.GetMonitorTimeList(17, "沉降", "下行线", "2011-1-1", "2014-1-1");

            var badTimeList2 = MetroDataQuery.Utility.MonitorPointsQuery.GetMonitorTimeList(17, "沉降", "下行线", "2011-1-1", "2014-1-1", 3);
        }


        [TestMethod]
        public void UpdateSQLGenerate()
        {
            //ar sql = MetroDataQuery.Utility.UpdateMonitorPoint.GenerateUpdateString(17, "XX03", 9.99, "2014-10-14", "MonitorPoints");
            var names = @"XX01
                        XX02
                        XX03
                        XX04
                        XX05
                        XX06
                        XX07
                        XX08
                        XX09
                        XX10".Replace("\r\n", ",").Split(',').Select(p => p.Trim()).ToArray();
            var values = @"-14.40226
                            -14.4453
                            -14.46336
                            -14.43688
                            -14.40078
                            -14.34057
                            -14.24812
                            -14.11951
                            -14.03666
                            -13.96548".Replace("\r\n", ",").Split(',')
                          .Select(p => Convert.ToDouble(p)).ToArray();
            var reviews = new bool[10];
            for (var i = 0; i < 10; i++)
            {
                reviews[i] = true;
            }

            MetroDataQuery.Utility.UpdateMonitorPointQuery.UpdatePoints(17, "2015-5-1", names, values, reviews);
        }


        [TestMethod]
        public void ApplyChangeValue()
        {
            MetroDataQuery.Utility.ChangeLogQuery.AddChangeLog(5, "XX01", 0.001, "2013-10-1");
        }

        [TestMethod]
        public void AddDataAfterChangelogChanged()
        {
            MetroDataQuery.Utility.UpdateMonitorPointQuery.UpdatePoints(5, "2014-10-24",
                new string[] { "XX01" }, new double[] { -14.40326 });
        }


        [TestMethod]
        public void GetRusultByNames()
        {
            var list =
            MetroDataQuery.Utility.MonitorPointsQuery.GetPointsValuesByNames(46, new string[] { "XX01", "XX03", "SX01", "SL01" }
            , "2013-8-22", false);
        }

        [TestMethod]
        public void AggregateMethod()
        {
            var list = new List<List<int>>();
            var list1 = new List<int>(new int[] { 2, 3, 4, 5 });
            var list2 = new List<int>(new int[] { 6, 7, 8, 9 });
            list.Add(list1); list.Add(list2);

            var result = list.Aggregate((a, b) => a.Concat(b).ToList());
        }


        [TestMethod]
        public void GetOriginValueInNewDataBase()
        {
            var result = MetroDataQuery.Utility.MonitorPointsQuery.GetOriginResults(17, "沉降", "上行线");
        }


        [TestMethod]
        public void GetOriginTime()
        {
            var result = MetroDataQuery.Utility.MonitorPointsQuery.GetOriginTime(17, "沉降", "上行线");
        }

        [TestMethod]
        public void GetOriginValue()
        {
            var result = MetroDataQuery.Utility.MonitorPointsQuery.GetOrigin(17, "LevelPoints1", "SX10");
        }


        [TestMethod]
        public void ApproveReview()
        {
            MetroDataQuery.Utility.ReviewMonitorPointsQuery.AddReviewToResult(17, "沉降", "下行线", "2015-5-1");
        }

        [TestMethod]
        public void DenyReview()
        {
            MetroDataQuery.Utility.ReviewMonitorPointsQuery.RemoveReviewResult(17, "沉降", "下行线", "2015-7-1");
        }

    }
}
